home *** CD-ROM | disk | FTP | other *** search
/ Aminet 43 / Aminet 43 (2001)(GTI - Schatztruhe)[!][Jun 2001].iso / Aminet / game / patch / WHD_JWSnooker.lha / WHD_JWSnooker / Install next >
Text File  |  2001-04-06  |  9KB  |  386 lines

  1. ;================================================================================
  2. ; CONFIGURATION SECTION
  3.  
  4. (set #CFG_APPNAME "Jimmy White's Whirlwind Snooker")
  5. (set #CFG_APPSLV  "JWWSHD")
  6. (set #CFG_APPGUI  "Jimmy White Snooker")
  7. (set #CFG_APPVER  "R0401.1")
  8. (set #CFG_APPCOPY "1998-2001")
  9.  
  10. ;================================================================================
  11.  
  12. ;------------------------------------------------------------------------------------
  13. ; Checks if given program is reachable via the path, if not abort install
  14. ;
  15. ; Entry:    #VP1 = name of program to search for
  16.  
  17. (procedure P_CheckRun (
  18.     (if (<> 0 (run (cat "Which " #VP1)))(
  19.         (abort
  20.             (cat
  21.                 "Could not find the program\n\n"
  22.                 "'" #VPROGRAM "'\n\n"
  23.                 "which is required to perform the installation!\n\n"
  24.                 "Please install the '" #VPROGRAM "' program ensuring that"
  25.                 " it is accessible on the path, then try the installation again."
  26.             )
  27.         )
  28.     ))
  29. ))
  30.  
  31.  
  32. ;------------------------------------------------------------------------------------
  33. ; Create installation directories if required
  34.  
  35. (procedure P_InstallDirs (
  36.     ;
  37.     ; Create data dir if required
  38.     ;
  39.     (if (<> 2 (exists #VDATDIR))(
  40.         (makedir #VDATDIR
  41.             (prompt "The directory '" #VDATDIR "' will now be created")
  42.             (help @makedir-help)
  43.             (confirm)
  44.         )
  45.     ))
  46. ))
  47.  
  48.  
  49. ;------------------------------------------------------------------------------------
  50. ; Determine and set information about version of game being installed
  51. ;
  52.  
  53. (procedure P_SetVersionInfo (
  54.     ; if the file exists, set version information
  55.     (if (<= #VVERINFA 0)(
  56.         (if (= 1 (exists #VDATFILE))(
  57.             ; determine version from CRC
  58.             (working "Determining game version")
  59.  
  60.             (set #VT1
  61.                 (run (cat "CRC16 \"" #VDATFILE "\" OFFSET=0 LENGTH=5120"))
  62.             )
  63.  
  64.             (set #VVERINFA 0)
  65.             (if (= #VT1 15255) (set #VVERINFA 1))
  66.             (if (= #VT1 55684) (set #VVERINFA 2))
  67.             (if (= #VT1 62221) (set #VVERINFA 3))
  68.             (if (= #VT1 34767) (set #VVERINFA 4))
  69.         ))
  70.     ))
  71. ))
  72.  
  73.  
  74. ;------------------------------------------------------------------------------------
  75. ; Make game data
  76.  
  77. (procedure P_InstallGame (
  78.     ;
  79.     ; Set path to game data file
  80.     ;
  81.     (set #VDATFILE (tackon #VDATDIR "Main"))
  82.  
  83.     ;
  84.     ; Install data files if not found or unknown versions
  85.     ;
  86.     (P_SetVersionInfo)
  87.        (if (<> 1 (exists (tackon #VDATDIR "SaveDat.6B4"))) (set #VVERINFA -1))
  88.     (if (<> 1 (exists (tackon #VDATDIR "SaveDat.6CA"))) (set #VVERINFA -1))
  89.  
  90.     (if (<= #VVERINFA 0)(
  91.         ;
  92.         ; Tell user what is happening
  93.         ;
  94.         (message
  95.             (cat
  96.                 "\n\n\nThe installer will now create the game data files\n"
  97.                 "Plese insert your game disk into drive DF0:\n\n"
  98.                 "Click 'Proceed' when ready."
  99.             )
  100.         )
  101.  
  102.         ;
  103.         ; Call the extractor slave
  104.         ;
  105.         (working "Creating data files in '" #VDATDIR "'")
  106.  
  107.         (copyfiles
  108.             (prompt "Copying data file creation slave")
  109.             (help @copyfiles-help)
  110.             (source "JWWSMakeDat")
  111.             (dest #VDESTDIR)
  112.             (nogauge)
  113.             (optional fail force)
  114.         )
  115.  
  116.         (set @execute-dir #VDESTDIR)
  117.         (run (cat "WHDLoad SLAVE=JWWSMakeDat"))
  118.         (set @execute-dir #VOLDEXEDIR)
  119.  
  120.         (delete (tackon #VDESTDIR "JWWSMakeDat") (optional force))
  121.     ))
  122.  
  123.     ;
  124.     ; Check the main data file was created and
  125.     ; that we know this version of the game
  126.     ;
  127.     (P_SetVersionInfo)
  128.        (if (<> 1 (exists (tackon #VDATDIR "SaveDat.6B4"))) (set #VVERINFA -1))
  129.     (if (<> 1 (exists (tackon #VDATDIR "SaveDat.6CA"))) (set #VVERINFA -1))
  130.  
  131.     (if (= 0 #VVERINFA)
  132.         (abort
  133.             (cat    "\n*** UNKNOWN VERSION OF GAME! ***\n\n"
  134.                     "The installer does not recognise the version of the\n"
  135.                     "game that you are trying to install.\n\n"
  136.                     "Please contact the author for further information\n"
  137.             )
  138.         )
  139.     )
  140.  
  141.     (if (= -1 #VVERINFA)
  142.         (abort
  143.             (cat    "\n*** DATA FILES NOT CREATED! ***\n\n"
  144.                     "The installer could not extract the game data files.\n\n"
  145.                     "Please contact the author for further information\n"
  146.             )
  147.         )
  148.     )
  149.  
  150.     ;
  151.     ; Clean up previous installations
  152.     ;
  153.     (set #VT1 (tackon #VDESTDIR "Install_JWWS_Save"))
  154.     (if (= 1 (exists #VT1)) (delete #VT1 (optional nofail force)) )
  155.  
  156.     (set #VT1 (tackon #VDESTDIR "Install_JWWS_Save.info"))
  157.     (set #VT2 (tackon #VDESTDIR "Install Saved Game.info"))
  158.     (if (= 1 (exists #VT2))
  159.         (if (= 1 (exists #VT1)) (delete #VT1 (optional nofail force)) )
  160.         (if (= 1 (exists #VT1)) (rename #VT1 #VT2) )
  161.     )
  162.  
  163.     ;
  164.     ; Copy support utilites and icons
  165.     ;
  166.     (copyfiles
  167.         (prompt "Copying save data extractor program")
  168.         (help @copyfiles-help)
  169.         (source "JWWSMakeSave")
  170.         (dest #VDATDIR)
  171.         (nogauge)
  172.         (noposition)
  173.         (optional fail force)
  174.     )
  175.  
  176.     (copyfiles
  177.         (prompt "Copying savegame installer script")
  178.         (help @copyfiles-help)
  179.         (source "InstallSG")
  180.         (newname "Install Saved Game")
  181.         (dest #VDESTDIR)
  182.         (nogauge)
  183.         (optional fail force)
  184.     )
  185.  
  186.     (set #VT1 (tackon #VDESTDIR "Install Saved Game.info"))
  187.     (if (= 0 (exists (tackon #VDESTDIR #VT1)))(
  188.         ; no icon exists, quietly copy one in
  189.         (set #VT2 1)
  190.     )(
  191.         ; icon exists, ask user if they want to overwrite it
  192.         (set #VT2
  193.             (askbool
  194.                 (prompt (cat "Do you want to replace the install saved game icon ?"))
  195.                 (default 1)
  196.                 (help @askchoice-help)
  197.             )
  198.         )
  199.     ))
  200.  
  201.     (if (= 1 #VT2)(
  202.         (copyfiles
  203.             (prompt "Copying savegame installer script icon")
  204.             (help @copyfiles-help)
  205.             (source "InstallSG.inf")
  206.             (newname "Install Saved Game.info")
  207.             (dest #VDESTDIR)
  208.             (nogauge)
  209.             (optional nofail force)
  210.         )
  211.     ))
  212. ))
  213.  
  214. ;------------------------------------------------------------------------------------
  215. ; Install WHDLoad slave program
  216.  
  217. (procedure P_InstallSlave (
  218.  
  219.     (working "Installing slave program")
  220.  
  221.     ; first, clean up previous installations
  222.     (set #VT1 (tackon #VDESTDIR "JW_Snooker"))
  223.     (if (= 1 (exists #VT1)) (delete #VT1 (optional force)) )
  224.  
  225.     (set #VT1 (tackon #VDESTDIR "JW_Snooker.info"))
  226.     (set #VT2 (tackon #VDESTDIR "Jimmy White Snooker.info"))
  227.     (if (= 1 (exists #VT2))
  228.         (if (= 1 (exists #VT1)) (delete #VT1 (optional nofail force)) )
  229.         (if (= 1 (exists #VT1)) (rename #VT1 #VT2) )
  230.     )
  231.  
  232.     ; copy slave program
  233.     (set #VT1 "Slave")
  234.     (if (>= #VVERINFA 0) (set #VT1 (cat #VT1 #VVERINFA)) )
  235.     (if (>= #VVERINFB 0) (set #VT1 (cat #VT1 #VVERINFB)) )
  236.     (if (>= #VVERINFC 0) (set #VT1 (cat #VT1 #VVERINFC)) )
  237.  
  238.     (copyfiles
  239.         (prompt "Copying slave program")
  240.         (help @copyfiles-help)
  241.         (source #VT1)
  242.         (newname #CFG_APPSLV)
  243.         (dest #VDESTDIR)
  244.         (nogauge)
  245.         (optional fail force)
  246.     )
  247.  
  248.     ; see if the user wants to replace their icon
  249.     (set #VT1 (cat #CFG_APPGUI ".info"))
  250.     (if (= 0 (exists (tackon #VDESTDIR #VT1)))(
  251.         ; no icon exists, quietly copy one in
  252.         (set #VT2 1)
  253.     )(
  254.         ; icon exists, ask user if they want to overwrite it
  255.         (set #VT2
  256.             (askbool
  257.                 (prompt (cat "Do you want to replace the \"" #CFG_APPGUI "\" program icon (recommended) ?"))
  258.                 (default 1)
  259.                 (help @askchoice-help)
  260.             )
  261.         )
  262.     ))
  263.  
  264.     ; do we have a slave icon?
  265.     (if (= 1 (exists "Slave.inf"))(
  266.         ; copy slave icon, renaming to proper name along the way
  267.         (if (= 1 #VT2)(
  268.             (copyfiles
  269.                 (prompt "Copying slave program icon")
  270.                 (help @copyfiles-help)
  271.                 (source "Slave.inf")
  272.                 (newname #VT1)
  273.                 (dest #VDESTDIR)
  274.                 (nogauge)
  275.                 (optional nofail force)
  276.             )
  277.         ))
  278.     )(
  279.         ; no slave icon so we must have a GUI to install
  280.         (copyfiles
  281.             (prompt "Copying GUI program")
  282.             (help @copyfiles-help)
  283.             (source  "GUI")
  284.             (newname #CFG_APPGUI)
  285.             (dest #VDESTDIR)
  286.             (nogauge)
  287.             (optional fail force)
  288.         )
  289.  
  290.         (if (= 1 #VT2)(
  291.             (copyfiles
  292.                 (prompt "Copying GUI program icon")
  293.                 (help @copyfiles-help)
  294.                 (source  "GUI.inf")
  295.                 (newname #VT1)
  296.                 (dest #VDESTDIR)
  297.                 (nogauge)
  298.                 (optional nofail force)
  299.             )
  300.         ))
  301.     ))
  302.  
  303. ))
  304.  
  305. ;------------------------------------------------------------------------------------
  306. (welcome (cat "Welcome to the " #CFG_APPNAME " HD Installer"))
  307.  
  308. ;
  309. ; Initialise
  310. ;
  311. (set @app-name #CFG_APPNAME)
  312. (set #VOLDEXEDIR @execute-dir)
  313. (set #VVERINFA -1)
  314. (set #VVERINFB -1)
  315. (set #VVERINFC -1)
  316. (set #VDESTDIR @default-dest)
  317.  
  318. ;
  319. ; Check settings
  320. ;
  321. (if    (<> @user-level 2)
  322.     (abort "You must select 'Expert' user level")
  323. )
  324.  
  325. (if    (< @installer-version 2818051)
  326.     (abort "This product requires at least version 43.3 of the Installer program")
  327. )
  328.  
  329. ;
  330. ; Check required programs are available
  331. ;
  332. (set #VP1 "CRC16")
  333. (P_CheckRun)
  334. (set #VP1 "RawDIC")
  335. (P_CheckRun)
  336. (set #VP1 "WHDLoad")
  337. (P_CheckRun)
  338.  
  339. ;
  340. ; Welcome message
  341. ;
  342. (message "\n\nWelcome to the " #CFG_APPNAME " HD Installer"
  343.          "\n© " #CFG_APPCOPY " John Girvin/Halibut Software\n\n"
  344.          "Please read the documentation thoroughly "
  345.          "before attempting to use this installer!\n\n"
  346.          "This is release " #CFG_APPVER "\n\n"
  347.          "Click 'Proceed' to begin..."
  348. )
  349.  
  350. ;
  351. ; Get directory to install in
  352. ;
  353. (set #VDESTDIR
  354.     (askdir
  355.         (prompt "Where would you like the game installed?\n"
  356.                 "If you have an existing installation select that directory,\n"
  357.                 "otherwise create / select the directory to install the game into."
  358.         )
  359.         (help @askdir-help)
  360.         (default @default-dest)
  361.         (disk)
  362.         (newpath)
  363.     )
  364. )
  365. (set #VDESTDIR (expandpath #VDESTDIR))
  366. (set @default-dest #VDESTDIR)
  367. (set #VDATDIR  (tackon #VDESTDIR "data/"))
  368.  
  369. ;
  370. ; Create the installation directories
  371. ;
  372. (P_InstallDirs)
  373.  
  374. ;
  375. ; Install the game data
  376. ;
  377. (P_InstallGame)
  378.  
  379. ;
  380. ; Install the slave
  381. ;
  382. (P_InstallSlave)
  383.  
  384. ;================================================================================
  385. ;$VER: JWWS Installer script R0401.1 © 1998-2001 John Girvin/Halibut Software;================================================================================
  386.